class Solution {
public:
    long long maxStrength(vector<int>& nums)
    {
        if (nums.size() == 1) return nums[0];
        long long ans = 1;
        //不能存在0 负数必须是偶数个 把0直接排除
        vector<int> neg;
        vector<int> pos;
        for (auto& a : nums)
        {
            if (a < 0) neg.push_back(a);
            if (a > 0) pos.push_back(a);
        }
        sort(neg.begin(), neg.end());
        int f = 0;
        for (auto& a : pos)
        {
            ans *= a;
            f = 1;
        }
        int flag = 0;
        if (neg.size() % 2 != 0) flag = 1;
        if (flag == 1)
            for (int i = 0; i < neg.size() - 1; i++)
            {
                ans *= neg[i];
                f = 1;
            }
        else
            for (auto& a : neg)
            {
                ans *= a;
                f = 1;
            }
        return f == 0 ? 0 : ans;
    }
};